*----------------------------------------------------------------------------------------------------------------------------------*

*Replication_DempseyIonescu_OLSRegression.do contains codes for OLS regression results in the paper shown in tables 4, 5, A.2 and A.3

*----------------------------------------------------------------------------------------------------------------------------------*


*This script generates OLS regression results in tables 4,5,A.2 and A.3

clear all

cd "/data/***"

*The results of the probit analysis are pulled in
use "average_apr_calculations_closed.dta"

************************

*Variable generation

************************

/*
The following variables are either defined or created in Replication_DempseyIonescu_ProbitRegression.do:
	-mean_borrower_income
	-fico_mean_2018
	-bank_fe_phat
	-mult_flag
	-revolver
	-new_account
	-m
	-uniqueid
	
New variables used in this script are defined below:

-mean_apr: The mean APR across 2018 for a given card. This value is taken from the original Y-14M variable cycleendingretailapr, line item 56

-prime_rate: The prime rate used is the FRED series DPRIME. The values are averaged over a given month, and then merged into the monthly Y-14M data.

-mean_spread: The mean difference between the APR and the prime rate for a given card. This is taken as a transformation of the Y-14M variable cycleendingretailapr, line item 56.
*/

bysort periodid: egen prime_rate = mean(DPRIME)

bysort uniqueid: egen apr_mean_2018 = mean(cycleendingretailapr)

gen spread = cycleendingretailapr - prime_rate

bysort uniqueid: egen mean_spread = mean(spread)

*Continuous variables are transformed into logs
gen log_spread = log(mean_spread)
gen log_income = log(mean_borrower_income)
gen log_fico = log(fico_mean_2018)
gen log_apr = log(apr_mean_2018)

drop if log_income == .

*bank_fe_phat are the predicted default probabilities that are generated by the probit analysis

rename bank_fe_phat default_prob

gen log_default = log(default_prob)


*Unique id is split into the id_rssd variable for bank-level fixed effects

split uniqueid, generate(id_rssd) parse("&")
encode id_rssd1, gen(id_rssd)

************************

*Regressions

************************

cd "/data/***/output"

*Table 4 ----------------------------------------------------------------------------------------------------------------


*Variables are added individually

quietly eststo r1: regress log_spread log_default
quietly eststo r2: regress log_spread log_default log_income
quietly eststo r3: regress log_spread log_default log_income i.mult_flag
quietly eststo r4: regress log_spread log_default log_income i.mult_flag revolver
quietly eststo r5: regress log_spread log_default log_income i.mult_flag revolver new_account 
quietly eststo r6: regress log_spread log_default log_income i.mult_flag revolver new_account i.m 
quietly eststo r7: regress log_spread log_default log_income i.mult_flag revolver new_account i.m i.id_rssd

*Final table is stored to table_4.tex

esttab r1 r2 r3 r4 r5 r6 r7 using table_4.tex, r2 se star starlevels(* 0.10 ** 0.05 *** 0.010) title(Table 4) numbers nobase keep(log_default log_income) indicate("Multiple Relationship = *.mult_flag" "Revolver = revolver" "New Account = new_account" "Time FE = *.m" "Bank FE = *.id_rssd" , labels("X")) replace


*Table 5 ----------------------------------------------------------------------------------------------------------------


*Borrower risk categories are created based on FICO score

gen borrower_risk = 3
replace borrower_risk = 2 if fico_mean_2018 > 620
replace borrower_risk = 1 if fico_mean_2018 > 720

*Spreads Prime

preserve

keep if borrower_risk == 1

eststo spread_1: regress log_spread log_default log_income i.mult_flag revolver new_account i.m i.id_rssd

restore

*Spreads Near-Prime

preserve

keep if borrower_risk == 2

eststo spread_2: regress log_spread log_default log_income i.mult_flag revolver new_account i.m i.id_rssd

restore

*Spreads Subprime

preserve

keep if borrower_risk == 3

eststo spread_3: regress log_spread log_default log_income i.mult_flag revolver new_account i.m i.id_rssd

restore

*Spreads All

eststo spread_all: regress log_spread log_default log_income i.mult_flag revolver new_account i.m i.id_rssd

*Final table is stored to table_5.tex

esttab spread_1 spread_2 spread_3 spread_all using table_5.tex, r2 se star starlevels(* 0.10 ** 0.05 *** 0.010) title(Table 5) mtitles(Prime Near-Prime Subprime All) numbers nobase keep(log_default log_income)


*Table A.2 ----------------------------------------------------------------------------------------------------------------

gen default_prob2 = default_prob^2

*Variables are added individually

quietly eststo r1: regress log_apr log_default
quietly eststo r2: regress log_apr log_default log_income
quietly eststo r3: regress log_apr log_default log_income i.mult_flag
quietly eststo r4: regress log_apr log_default log_income i.mult_flag revolver
quietly eststo r5: regress log_apr log_default log_income i.mult_flag revolver new_account 
quietly eststo r6: regress log_apr log_default log_income i.mult_flag revolver new_account i.m 
quietly eststo r7: regress log_apr log_default log_income i.mult_flag revolver new_account i.m i.id_rssd

*Final table is stored to table_A2A.tex

esttab r1 r2 r3 r4 r5 r6 r7 using table_A2A.tex, r2 se star starlevels(* 0.10 ** 0.05 *** 0.010) title(Table A.2A) numbers nobase keep(log_default log_income) indicate("Multiple Relationship = *.mult_flag" "Revolver = revolver" "New Account = new_account" "Time FE = *.m" "Bank FE = *.id_rssd" , labels("X")) replace

quietly eststo r1: regress log_spread default_prob default_prob2
quietly eststo r2: regress log_spread default_prob default_prob2 log_income
quietly eststo r3: regress log_spread default_prob default_prob2 log_income i.mult_flag
quietly eststo r4: regress log_spread default_prob default_prob2 log_income i.mult_flag revolver
quietly eststo r5: regress log_spread default_prob default_prob2 log_income i.mult_flag revolver new_account 
quietly eststo r6: regress log_spread default_prob default_prob2 log_income i.mult_flag revolver new_account i.m 
quietly eststo r7: regress log_spread default_prob default_prob2 log_income i.mult_flag revolver new_account i.m i.id_rssd

*Final table is stored to table_A2B.tex

esttab r1 r2 r3 r4 r5 r6 r7 using table_A2B.tex, r2 se star starlevels(* 0.10 ** 0.05 *** 0.010) title(Table A.2B) numbers nobase keep(default_prob default_prob2 log_income) indicate("Multiple Relationship = *.mult_flag" "Revolver = revolver" "New Account = new_account" "Time FE = *.m" "Bank FE = *.id_rssd" , labels("X")) replace


*Table A.3 ----------------------------------------------------------------------------------------------------------------


*Borrower risk categories are created based on default probabilities

gen borrower_risk = 1
replace borrower_risk = 2 if log_default > 0.01
replace borrower_risk = 3 if log_default > 0.10

*Spreads Low Risk

preserve

keep if borrower_risk == 1

eststo spread_1: regress log_spread log_default log_income i.mult_flag revolver new_account i.m i.id_rssd

restore

*Spreads Medium Risk

preserve

keep if borrower_risk == 2

eststo spread_2: regress log_spread log_default log_income i.mult_flag revolver new_account i.m i.id_rssd

restore

*Spreads High Risk

preserve

keep if borrower_risk == 3

eststo spread_3: regress log_spread log_default log_income i.mult_flag revolver new_account i.m i.id_rssd

restore

*Spreads All

eststo spread_all: regress log_spread log_default log_income i.mult_flag revolver new_account i.m i.id_rssd

*Final table is stored to table_A3.tex

esttab spread_1 spread_2 spread_3 spread_all using table_A3.tex, r2 se star starlevels(* 0.10 ** 0.05 *** 0.010) title(Table A3) mtitles(Low Medium High All) numbers nobase keep(log_default log_income)
